<?php 
function getUserRole(){
	//get logged-in user role
    $CI =& get_instance();
	$role = null;
    $user_id = $CI->session->userdata('user_id');
    if ($user_id > 0){
    	$query = $CI->db->get_where('users', array('id' => $user_id), 1);
    	foreach ($query->result() as $row){
    		$role = $row->role;
    	}
    } else {
    	$role = 'guest';	
    }
    return $role;
}
?>